<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../templates/StakeholderPortalTemplate.xhtml">

    <ui:define name="content"> 
        <f:view beforePhase="#{stakeholderULPManagerBean.initULPItemList}"></f:view>
            <h:form id="formMain">
                <h1>View All ULP Items</h1>         

                <p:panel header="View Offered ULP Items (Double click to select)">
                    <p:accordionPanel autoHeight="false">
                        <p:tab title="Currently Offered ULP Items">
                            <p:dataTable var="currentULPItem" value="#{stakeholderULPManagerBean.currentULPItemList}" paginator="true" 
                                         rows="10" emptyMessage="No ULP Item is being offered at the moment" selection="#{stakeholderULPManagerBean.selectedULPItem}" 
                                         selectionMode="single" rowSelectListener="#{stakeholderULPManagerBean.onRowSelectNavigateULPItem}"
                                         dblClickSelect="true">
                                <p:column sortBy="#{currentULPItem.ULPItem.id}" filterBy="#{currentULPItem.ULPItem.id}">
                                    <f:facet name="header">
                                        <h:outputText value="ID" />
                                    </f:facet>
                                    <h:outputText value="#{currentULPItem.ULPItem.id}" />
                                </p:column>

                                <p:column sortBy="#{currentULPItem.ULPItem.stakeholder.corpName}" filterBy="#{currentULPItem.ULPItem.stakeholder.corpName}">
                                    <f:facet name="header">
                                        <h:outputText value="Offered by" />
                                    </f:facet>
                                    <h:outputText value="#{currentULPItem.ULPItem.stakeholder.corpName}" />
                                </p:column>

                                <p:column sortBy="#{currentULPItem.ULPItem.name}" filterBy="#{currentULPItem.ULPItem.name}">
                                    <f:facet name="header">
                                        <h:outputText value="Name" />
                                    </f:facet>
                                    <h:outputText value="#{currentULPItem.ULPItem.name}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Image" />
                                    </f:facet>
                                    <p:graphicImage id="imageDisplay" value="/images/upload/media/#{currentULPItem.ULPItem.imageURL}"
                                                    height="50" width="70"/> 
                                </p:column>  

                                <p:column sortBy="#{currentULPItem.ULPItem.pointsToRedeem}" filterBy="#{currentULPItem.ULPItem.pointsToRedeem}">
                                    <f:facet name="header">
                                        <h:outputText value="Points To Redeem" />
                                    </f:facet>
                                    <h:outputText value="#{currentULPItem.ULPItem.pointsToRedeem} points" />
                                </p:column>

                                <p:column sortBy="#{currentULPItem.ULPItem.costOfItem}" filterBy="#{currentULPItem.ULPItem.costOfItem}">
                                    <f:facet name="header">
                                        <h:outputText value="Item Cost" />
                                    </f:facet>
                                    <h:outputText value="#{currentULPItem.ULPItem.costOfItem} SGD" />
                                </p:column>


                                <p:column sortBy="#{currentULPItem.ULPItem.validUntil}" filterBy="#{currentULPItem.ULPItem.validUntil}">
                                    <f:facet name="header">
                                        <h:outputText value="Offer Until" />
                                    </f:facet>
                                    <h:outputText value="#{currentULPItem.ULPItem.validUntil}">
                                        <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                    </h:outputText>
                                </p:column>

                                <p:column sortBy="#{currentULPItem.quantityRedeemed}" filterBy="#{currentULPItem.quantityRedeemed}">
                                    <f:facet name="header">
                                        <h:outputText value="Quantity Redeemed" />
                                    </f:facet>
                                    <h:outputText value="#{currentULPItem.quantityRedeemed}" />
                                </p:column>

                                <p:column sortBy="#{currentULPItem.quantityUsed}" filterBy="#{currentULPItem.quantityUsed}">
                                    <f:facet name="header">
                                        <h:outputText value="Quantity Used" />
                                    </f:facet>
                                    <h:outputText value="#{currentULPItem.quantityUsed}" />
                                </p:column>

                                <p:column sortBy="#{currentULPItem.ULPItem.status}" filterBy="#{currentULPItem.ULPItem.status}">
                                    <f:facet name="header">
                                        <h:outputText value="Status" />
                                    </f:facet>
                                    <h:outputText value="#{currentULPItem.ULPItem.status}" />
                                </p:column>

                            </p:dataTable>
                        </p:tab>

                        <p:tab title="Past ULP Items">
                            <p:dataTable var="pastULPItem" value="#{stakeholderULPManagerBean.expiredULPItemList}" paginator="true" 
                                         rows="10" emptyMessage="No ULP Item is being offered at the moment" selection="#{stakeholderULPManagerBean.selectedULPItem}" 
                                         selectionMode="single" rowSelectListener="#{stakeholderULPManagerBean.onRowSelectNavigateULPItem}"
                                         dblClickSelect="true">
                                <p:column sortBy="#{pastULPItem.ULPItem.id}" filterBy="#{pastULPItem.ULPItem.id}">
                                    <f:facet name="header">
                                        <h:outputText value="ID" />
                                    </f:facet>
                                    <h:outputText value="#{pastULPItem.ULPItem.id}" />
                                </p:column>

                                <p:column sortBy="#{pastULPItem.ULPItem.stakeholder.corpName}" filterBy="#{pastULPItem.ULPItem.stakeholder.corpName}">
                                    <f:facet name="header">
                                        <h:outputText value="Offered by" />
                                    </f:facet>
                                    <h:outputText value="#{pastULPItem.ULPItem.stakeholder.corpName}" />
                                </p:column>

                                <p:column sortBy="#{pastULPItem.ULPItem.name}" filterBy="#{pastULPItem.ULPItem.name}">
                                    <f:facet name="header">
                                        <h:outputText value="Name" />
                                    </f:facet>
                                    <h:outputText value="#{pastULPItem.ULPItem.name}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Image" />
                                    </f:facet>
                                    <p:graphicImage id="imageDisplay" value="/images/upload/media/#{pastULPItem.ULPItem.imageURL}"
                                                    height="50" width="70"/> 
                                </p:column>  

                                <p:column sortBy="#{pastULPItem.ULPItem.pointsToRedeem}" filterBy="#{pastULPItem.ULPItem.pointsToRedeem}">
                                    <f:facet name="header">
                                        <h:outputText value="Points To Redeem" />
                                    </f:facet>
                                    <h:outputText value="#{pastULPItem.ULPItem.pointsToRedeem}" />
                                </p:column>

                                <p:column sortBy="#{pastULPItem.ULPItem.costOfItem}" filterBy="#{pastULPItem.ULPItem.costOfItem}">
                                    <f:facet name="header">
                                        <h:outputText value="Item Cost" />
                                    </f:facet>
                                    <h:outputText value="#{pastULPItem.ULPItem.costOfItem}" />
                                </p:column>


                                <p:column sortBy="#{pastULPItem.ULPItem.validUntil}" filterBy="#{pastULPItem.ULPItem.validUntil}">
                                    <f:facet name="header">
                                        <h:outputText value="End Date" />
                                    </f:facet>
                                    <h:outputText value="#{pastULPItem.ULPItem.validUntil}" />
                                </p:column>

                                <p:column sortBy="#{pastULPItem.quantityRedeemed}" filterBy="#{pastULPItem.quantityRedeemed}">
                                    <f:facet name="header">
                                        <h:outputText value="Quantity Redeemed" />
                                    </f:facet>
                                    <h:outputText value="#{pastULPItem.quantityRedeemed}" />
                                </p:column>

                                <p:column sortBy="#{pastULPItem.quantityUsed}" filterBy="#{pastULPItem.quantityUsed}">
                                    <f:facet name="header">
                                        <h:outputText value="Quantity Used" />
                                    </f:facet>
                                    <h:outputText value="#{pastULPItem.quantityUsed}" />
                                </p:column>

                                <p:column sortBy="#{pastULPItem.ULPItem.status}" filterBy="#{pastULPItem.ULPItem.status}">
                                    <f:facet name="header">
                                        <h:outputText value="Status" />
                                    </f:facet>
                                    <h:outputText value="#{pastULPItem.ULPItem.status}" />
                                </p:column>

                            </p:dataTable>
                        </p:tab>
                    </p:accordionPanel> 
                </p:panel>
            </h:form>
    </ui:define>
</ui:composition>